package com.njbw.design_pattern.created.prototype.deepCopy;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 产品类
 *
 * @author 黄侯淳
 * @since JDK 1.8
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Product implements Cloneable, Serializable {

    /**
     * 产品名称
     */
    private String name;

    /**
     * 产品价格
     */
    private Double price;

    /**
     * 产品库存
     */
    private Integer stock;

    @Override
    public Product clone() {
        try {
            // TODO: copy mutable state here, so the clone can't change the internals of the original
            return (Product) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}
